<div class="filter">
    <div class="item" style="line-height: 30px; padding-left: 10px;">请选择游戏</div>
    <div class="f1 item">
        <select data-am-selected>
            <option value="bjpk10"></option>
            <option value="zypk10"></option>
            <option value="cqssc"></option>
            <option value="xjssc"></option>
            <option value="tjssc"></option>
            <option value="zyssc"></option>
            <option value="ffcqq"></option>
            <option value="gd115"></option>
            <option value="zy115"></option>
        </select>
    </div>
    <div class="clear"></div>
</div>

<div class="game-bjpk10 _aaa">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单号1-10</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当冠军（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>

<div class="game-zypk10 _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单号1-10</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当冠军（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>

<div class="game-cqssc _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球0-9</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>
<div class="game-xjssc _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球0-9</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>
<div class="game-tjssc _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球0-9</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>
<div class="game-zyssc _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球0-9</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>
<div class="game-ffcqq _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球0-9</th>
            <td>
                <input type="number" name="limit" placeholder="0或者10为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>
<div class="game-gd115 _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球1-11</th>
            <td>
                <input type="number" name="limit" placeholder="0或者11为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>
<div class="game-zy115 _aaa" style="display: none;">
    <table class="form-table-without-line">
        <tr class="client_title">
            <th>单球1-11</th>
            <td>
                <input type="number" name="limit" placeholder="0或者11为不限制" class="am-form-field" required/>
                <div class="red" style="line-height: 30px;">
                    【提示】如果填写8，当第一球（其他同）投注超过8个号码，将被禁止
                </div>
                <button type="button" class="btn-name">保存</button>
            </td>
        </tr>
    </table>
</div>

<script>
    var arr = $(".f1 option");
    for (var i = 0; i < arr.length; i++) {
        var type = $(arr[i]).attr("value");
        $(arr[i]).html(get_game_display_name(type));
        queryNumberLimit(type, "limit");

        registerBtnClick(type);
    }

    // 按钮被点击的处理
    function registerBtnClick(type) {
        $(".game-" + type + " button").click(function() {
            saveNumberLimit(type, "limit");
        });
    }

    // 获取数据
    function queryNumberLimit(type, name) {
        Classify.query("number.limit." + type, name, false, 0, function(v) {
            var k = '.game-__type__ input[name="__name__"]';
            k = k.replace(/__type__/, type);
            k = k.replace(/__name__/, name);
            $(k).val(v);
        });
    }

    // 保存数据
    function saveNumberLimit(type, name) {
        var k = '.game-__type__ input[name="__name__"]';
        k = k.replace(/__type__/, type);
        k = k.replace(/__name__/, name);
        var v = $(k).val();
        startLoading();
        Classify.save("number.limit." + type, name, v, function() {
            stopLoading();
            alert2("保存完成！");
        });
    }

    function doSwitchType() {
        var type = $(".f1 select").val();
        $("._aaa").hide();
        $(".game-" + type).show();
    }
    doSwitchType();
    $(".f1 select").change(doSwitchType);


</script>